package com.example.moviegroup.activity;

import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageView;

import com.example.moviegroup.R;

/**
 * Created by walymin-love on 2015/11/19.
 */
public class MoveMessageActivity extends Activity implements View.OnClickListener {
    ImageView image;
    ObjectAnimator anim;
    Button btn_back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_move);
        initView();
        initData();
        setListener();
    }

    public void initView() {
        image = (ImageView) findViewById(R.id.iv_move);
        btn_back = (Button) findViewById(R.id.btn_back_movem);
    }

    public void setListener() {
        image.setOnClickListener(this);
        btn_back.setOnClickListener(this);
    }

    public void initData() {
        anim = ObjectAnimator.ofFloat(image,"translationX",0,-150);
        anim.setDuration(1000);
        anim.setRepeatCount(Integer.MAX_VALUE);
        anim.setRepeatMode(Animation.REVERSE);
        anim.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        anim.cancel();
    }

    @Override
    protected void onResume() {
        super.onResume();
        anim.start();
    }

    @Override
    protected void onPause() {
        super.onPause();
        anim.cancel();
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.iv_move:
                Intent intnet1 = new Intent(MoveMessageActivity.this,LoginActivity.class);
                startActivity(intnet1);
                break;
            case R.id.btn_back_movem:
                finish();
                break;
        }
    }
}
